<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>materiald</title>
    <script type="text/javascript">
    	var dialog;
        var gridManager = null;
        $(function (){
        	$(".l-toolbar-item").hover(
        		function (){
                	$(this).addClass("l-panel-btn-over");
            }, function (){
                	$(this).removeClass("l-panel-btn-over");
            });
        	
        	$(".l-toolbar-item").click(function(){
        		toolbarBtnItemClick($(this));
        	});

            $("#maingrid").ligerGrid({
                columns: [
                          { display: '代码', name: 'id', align: 'cneter', width:'20%', minWidth: 50 },
                          { display: '教材名称', name: 'title', align: 'left', width:'30%',minWidth: 100 },
                          { display: '教材介绍', name: 'intro', align: 'left', width:'50%',minWidth: 100 }
                ], dataAction: 'server', url: '${ctx}/qso/materiald/list', sortName: 'id',
                width: '100%', height: '100%', numPerPage:20,rownumbers:true,
                checkbox : true,
                heightDiff: -6
            });
             
            gridManager = $("#maingrid").ligerGetGridManager();

            $("#pageloading").hide();
        });

        function search(){
            if (!gridManager) return;
            var id = $("#id").val();// 获取年级编号
            var title = $("#title").val(); //获取年级名称
            gridManager.setOptions(
                { parms: [{name:'search_LIKE_id',value:id},{ name: 'search_LIKE_title', value: title}]}
            );
            gridManager.loadData(true);
        }
        
        function onRead(){
        	if (!gridManager) return;
        	var row = gridManager.getSelected();
        	if (!row){
            	alert('请选择行');
            }else{
            	 $.ligerDialog.confirm('确认把所选课件复制到我的书柜吗？', function (yes)
                 {
            		 //实现复制课件到我的书柜
            		 var rows=gridManager.getCheckedRows();
           
            	 	 var rowIds="";
            		 for(var i=0;i<rows.length;i++){
            		 	rowIds+=rows[i].id+",";
            	 	 }
					 LG.ajax({
					 	url : '${ctx}/qso/bookcase/save',
					 	loading : '正在复制中...',
					 	data : {
						 	ids : rowIds
					 	},
					 	success : function(result) {
						 	LG.showSuccess(result.message);
							 	reload();
						 },
					 	error : function(result) {
						 	LG.showError(result.message);
					 	}
					});
				 });
			 }
		 }

		 function reload() {
			 gridManager.loadData();
		 }
	 </script>
</head>
<body style="padding:0px; overflow:hidden;"> 
<div class="l-loading" style="display:block" id="pageloading"></div> 

<div style=" width:100%" id="mainsearch">
    <div class="searchtitle">
        <span>搜索</span>
        <img src="${ctx}/static/icons/32X32/searchtool.gif"/>
        <div class="togglebtn"></div> 
    </div>
    <div class="searchbox">
        <form class="l-form" id="formsearch" ligeruiid="formsearch">
        	<ul>
        		<li style="width:90px;text-align:left;">教材编号：</li>
        		<li style="width:180px;text-align:left;">
	        		<div class="l-text" style="width: 178px;">
	        			<input type="text" ligerui="{&quot;width&quot;:178}" id="id" ltype="text" class="field l-text-field" style="width: 174px;">
	        			<div class="l-text-l"></div>
	        			<div class="l-text-r"></div>
	        		</div>
        		</li>
        		<li style="width:90px;text-align:left;">教材名称：</li>
        		<li style="width:180px;text-align:left;">
	        		<div class="l-text" style="width: 178px;">
	        			<input type="text" ligerui="{&quot;width&quot;:178}" id="title" ltype="text" class="field l-text-field" style="width: 174px;">
	        			<div class="l-text-l"></div>
	        			<div class="l-text-r"></div>
	        		</div>
        		</li>
        		<li style="width:40px;"></li>
        		<li style="margin-right:8px">
        			<div style="width:60px" class="button button2 buttonnoicon" onclick="onRead()">
	        			<div class="button-l"> </div>
	        			<div class="button-r"> </div> 
	        			<span>调阅</span>
        			</div>
        		</li>
        		<li style="margin-right:8px">
        			<div style="width:60px" class="button button2 buttonnoicon" onclick="search()">
	        			<div class="button-l"> </div>
	        			<div class="button-r"> </div> 
	        			<span>查询</span>
        			</div>
        		</li>
        	</ul>
        	<div class="l-clear"></div>
        </form>
    </div>
</div>

<div id="maingrid" style="margin:0; padding:0"></div>

<div style="display:none;"></div>
 
</body>
</html>
